//
//  ADLViewController.swift
//  PassValueDemo
//
//  Created by MAC on 2020/8/19.
//  Copyright © 2020 MAC. All rights reserved.
//

import UIKit
//MARK:- 页面 2

class ADLViewController: UIViewController {

    var textF = UITextField()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        //传值的输入框
        textF.frame = CGRect(x: 50, y: 170, width: view.frame.size.width - 100, height: 50)
        textF.attributedPlaceholder = NSAttributedString(string: "请输入要传的值", attributes: [NSAttributedString.Key.foregroundColor : UIColor.init(red: 1.000, green: 1.000, blue: 1.000, alpha: 0.5)])
        textF.borderStyle = .line
        textF.textColor = .white
        textF.backgroundColor = UIColor.init(red: 0.283, green: 0.290, blue: 0.293, alpha: 1)
        view.addSubview(textF)
        
        let btn = UIButton()
        btn.frame = CGRect(x: 70, y: (textF.frame.origin.y+textF.frame.size.height)+50, width: view.bounds.width-(70*2), height: 50)
        btn.backgroundColor = .orange
        btn.setTitle("开始传值了", for: .normal)
        btn.addTarget(self, action: #selector(btnAction(btn:)), for: .touchUpInside)
        
        view.addSubview(btn)
      
    }
    
    @objc func btnAction(btn:UIButton){
        //获取输入框内容，并给单例类属性赋值
        HYSingle.sharedInstance.sendValue = textF.text!
        //返回上级页面
        self.navigationController?.popViewController(animated: true)
    }
}
